package com.zhangtingshu.controller;

import com.zhangtingshu.service.impl.InvitationServiceImpl;
import com.zhangtingshu.vo.ChartInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @author zhangtingshu
 * 图表控制器
 */
@Controller
public class ChartController {

    @Autowired
    private InvitationServiceImpl invitationService;

    @RequestMapping("/tochartstat")
    public String tochartstat() {
        return "chartstat";
    }

    /**
     * 绘制饼图
     *
     * @return JSON集合
     */
    @RequestMapping("/chartfirst")
    public @ResponseBody
    List<ChartInfo> charFirst() {
        List<ChartInfo> list = invitationService.findStatPie();
        return list;
    }

    /**
     * 绘制柱状图
     *
     * @return JSON集合
     */
    @RequestMapping("/chartsecond")
    public @ResponseBody
    Map<String, List> charSecond() {
        Map<String, List> map = invitationService.findStatBar();
        return map;
    }

}
